]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: Do not warn about missing GDM on each login
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 20 Mar 2020 11:42:04 +0000 (12:42 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 25 Mar 2020 20:03:01 +0000 (20:03 +0000)
We now warn on startup if screen locking isn't available, however for
users who choose not to use GDM or logind, repeating the warning on
each login is more annoying than helpful.

Instead, limit the warning to the first login on which the screen lock
became unavailable. That way the notification will still serve the
intended purpose of informing the user, but without being perceived
as nagging.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432

js/ui/main.js

index b2936042398ccd69772b2787f943158ce45c56e5..ebf9b333a839639838113cdc6bcea621c78a5596 100644 (file)
@@ -93,6 +93,9 @@ let _a11ySettings = null;
 let _themeResource = null;
 let _oskResource = null;
 
+Gio._promisify(Gio._LocalFilePrototype, 'delete_async', 'delete_finish');
+Gio._promisify(Gio._LocalFilePrototype, 'touch_async', 'touch_finish');
+
 function _sessionUpdated() {
     if (sessionMode.isPrimary)
         _loadDefaultStylesheet();
@@ -276,11 +279,8 @@ function _initializeUI() {
         }
 
         if (sessionMode.currentMode !== 'gdm' &&
-            sessionMode.currentMode !== 'initial-setup' &&
-            screenShield === null) {
-            notify(_('Screen Lock disabled'),
-                   _('Screen Locking requires the GNOME display manager.'));
-        }
+            sessionMode.currentMode !== 'initial-setup')
+            _handleLockScreenWarning();
 
         LoginManager.registerSessionWithGDM();
 
@@ -293,6 +293,32 @@ function _initializeUI() {
     });
 }
 
+async function _handleLockScreenWarning() {
+    const path = '%s/lock-warning-shown'.format(global.userdatadir);
+    const file = Gio.File.new_for_path(path);
+
+    const hasLockScreen = screenShield !== null;
+    if (hasLockScreen) {
+        try {
+            await file.delete_async(0, null);
+        } catch (e) {
+            if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
+                logError(e);
+        }
+    } else {
+        try {
+            if (!await file.touch_async())
+                return;
+        } catch (e) {
+            logError(e);
+        }
+
+        notify(
+            _('Screen Lock disabled'),
+            _('Screen Locking requires the GNOME display manager.'));
+    }
+}
+
 function _getStylesheet(name) {
     let stylesheet;